<template>
  <div class="pagination-container">
    <el-pagination
      small
      background
      class="mt-3"
      :total="obj.total"
      v-bind="$attrs"
      :current-page="queryInfo.pagenum"
      :page-sizes="[5, 10, 20, 30, 50]"
      :page-size="queryInfo.pagesize"
      layout="total,sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "Pagination",
  props: ["obj"],
  methods: {
    // 监听 pagesize 改变的事件
    handleSizeChange(newSize) {
      // console.log(newSize);
      this.queryInfo.pagesize = newSize;
      this.$emit("pagination", { newSize });
    },
    // 监听 页码值 改变的事件
    handleCurrentChange(newPage) {
      // console.log(newPage);
      this.queryInfo.pagenum = newPage;
      this.$emit("pagination", { newPage });
    },
  },
};
</script>
